package com.example.demo.controller;

import com.example.demo.pojo.Response;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {
    Response response = new Response();

    @GetMapping("/")
    public ResponseEntity<Response> HelloWorld() {
        try {
            System.out.println("hello world!");
            response.setCode(200);
            response.setMessage("hello world!");
            return ResponseEntity.ok(response);
        } catch (Exception e) {
            response.setCode(400);
            response.setMessage("Bad Request: " + e.getMessage());
            return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(response);
        }
    }
}
